﻿
namespace caedisi.Web.Services
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data;
    using System.Linq;
    using System.ServiceModel.DomainServices.EntityFramework;
    using System.ServiceModel.DomainServices.Hosting;
    using System.ServiceModel.DomainServices.Server;
    using caedisi.Web.DataModel;
    
    
    // Implements application logic using the CellularAutomataDatabaseEntities context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    public partial class CellularAutomataDomainService : LinqToEntitiesDomainService<CellularAutomataDatabaseEntities>
    {
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Cells' query.
        public IQueryable<Cell> GetCells()
        {
            return this.ObjectContext.Cells;
        }
        
        public void InsertCell(Cell cell)
        {
            if ((cell.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(cell, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Cells.AddObject(cell);
            }
        }
        
        public void UpdateCell(Cell currentCell)
        {
            this.ObjectContext.Cells.AttachAsModified(currentCell, this.ChangeSet.GetOriginal(currentCell));
        }
        
        public void DeleteCell(Cell cell)
        {
            if ((cell.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(cell, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Cells.Attach(cell);
                this.ObjectContext.Cells.DeleteObject(cell);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'CellStateTypes' query.
        public IQueryable<CellStateType> GetCellStateTypes()
        {
            return this.ObjectContext.CellStateTypes;
        }
        
        public void InsertCellStateType(CellStateType cellStateType)
        {
            if ((cellStateType.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(cellStateType, EntityState.Added);
            }
            else
            {
                this.ObjectContext.CellStateTypes.AddObject(cellStateType);
            }
        }
        
        public void UpdateCellStateType(CellStateType currentCellStateType)
        {
            this.ObjectContext.CellStateTypes.AttachAsModified(currentCellStateType, this.ChangeSet.GetOriginal(currentCellStateType));
        }
        
        public void DeleteCellStateType(CellStateType cellStateType)
        {
            if ((cellStateType.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(cellStateType, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.CellStateTypes.Attach(cellStateType);
                this.ObjectContext.CellStateTypes.DeleteObject(cellStateType);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'CellularAutomatas' query.
        public IQueryable<CellularAutomata> GetCellularAutomatas()
        {
            return this.ObjectContext.CellularAutomatas;
        }
        
        public void InsertCellularAutomata(CellularAutomata cellularAutomata)
        {
            if ((cellularAutomata.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(cellularAutomata, EntityState.Added);
            }
            else
            {
                this.ObjectContext.CellularAutomatas.AddObject(cellularAutomata);
            }
        }
        
        public void UpdateCellularAutomata(CellularAutomata currentCellularAutomata)
        {
            this.ObjectContext.CellularAutomatas.AttachAsModified(currentCellularAutomata, this.ChangeSet.GetOriginal(currentCellularAutomata));
        }
        
        public void DeleteCellularAutomata(CellularAutomata cellularAutomata)
        {
            if ((cellularAutomata.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(cellularAutomata, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.CellularAutomatas.Attach(cellularAutomata);
                this.ObjectContext.CellularAutomatas.DeleteObject(cellularAutomata);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'Configurations' query.
        public IQueryable<Configuration> GetConfigurations()
        {
            return this.ObjectContext.Configurations;
        }
        
        public void InsertConfiguration(Configuration configuration)
        {
            if ((configuration.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(configuration, EntityState.Added);
            }
            else
            {
                this.ObjectContext.Configurations.AddObject(configuration);
            }
        }
        
        public void UpdateConfiguration(Configuration currentConfiguration)
        {
            this.ObjectContext.Configurations.AttachAsModified(currentConfiguration, this.ChangeSet.GetOriginal(currentConfiguration));
        }
        
        public void DeleteConfiguration(Configuration configuration)
        {
            if ((configuration.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(configuration, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Configurations.Attach(configuration);
                this.ObjectContext.Configurations.DeleteObject(configuration);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'NeighbourhoodStateConfigurations' query.
        public IQueryable<NeighbourhoodStateConfiguration> GetNeighbourhoodStateConfigurations()
        {
            return this.ObjectContext.NeighbourhoodStateConfigurations;
        }
        
        public void InsertNeighbourhoodStateConfiguration(NeighbourhoodStateConfiguration neighbourhoodStateConfiguration)
        {
            if ((neighbourhoodStateConfiguration.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(neighbourhoodStateConfiguration, EntityState.Added);
            }
            else
            {
                this.ObjectContext.NeighbourhoodStateConfigurations.AddObject(neighbourhoodStateConfiguration);
            }
        }
        
        public void UpdateNeighbourhoodStateConfiguration(NeighbourhoodStateConfiguration currentNeighbourhoodStateConfiguration)
        {
            this.ObjectContext.NeighbourhoodStateConfigurations.AttachAsModified(currentNeighbourhoodStateConfiguration, this.ChangeSet.GetOriginal(currentNeighbourhoodStateConfiguration));
        }
        
        public void DeleteNeighbourhoodStateConfiguration(NeighbourhoodStateConfiguration neighbourhoodStateConfiguration)
        {
            if ((neighbourhoodStateConfiguration.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(neighbourhoodStateConfiguration, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.NeighbourhoodStateConfigurations.Attach(neighbourhoodStateConfiguration);
                this.ObjectContext.NeighbourhoodStateConfigurations.DeleteObject(neighbourhoodStateConfiguration);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'NeighbourhoodTypes' query.
        public IQueryable<NeighbourhoodType> GetNeighbourhoodTypes()
        {
            return this.ObjectContext.NeighbourhoodTypes;
        }
        
        public void InsertNeighbourhoodType(NeighbourhoodType neighbourhoodType)
        {
            if ((neighbourhoodType.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(neighbourhoodType, EntityState.Added);
            }
            else
            {
                this.ObjectContext.NeighbourhoodTypes.AddObject(neighbourhoodType);
            }
        }
        
        public void UpdateNeighbourhoodType(NeighbourhoodType currentNeighbourhoodType)
        {
            this.ObjectContext.NeighbourhoodTypes.AttachAsModified(currentNeighbourhoodType, this.ChangeSet.GetOriginal(currentNeighbourhoodType));
        }
        
        public void DeleteNeighbourhoodType(NeighbourhoodType neighbourhoodType)
        {
            if ((neighbourhoodType.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(neighbourhoodType, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.NeighbourhoodTypes.Attach(neighbourhoodType);
                this.ObjectContext.NeighbourhoodTypes.DeleteObject(neighbourhoodType);
            }
        }
        
        // TODO:
        // Consider constraining the results of your query method.  If you need additional input you can
        // add parameters to this method or create additional query methods with different names.
        // To support paging you will need to add ordering to the 'TransitionRules' query.
        public IQueryable<TransitionRule> GetTransitionRules()
        {
            return this.ObjectContext.TransitionRules;
        }
        
        public void InsertTransitionRule(TransitionRule transitionRule)
        {
            if ((transitionRule.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(transitionRule, EntityState.Added);
            }
            else
            {
                this.ObjectContext.TransitionRules.AddObject(transitionRule);
            }
        }
        
        public void UpdateTransitionRule(TransitionRule currentTransitionRule)
        {
            this.ObjectContext.TransitionRules.AttachAsModified(currentTransitionRule, this.ChangeSet.GetOriginal(currentTransitionRule));
        }
        
        public void DeleteTransitionRule(TransitionRule transitionRule)
        {
            if ((transitionRule.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(transitionRule, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.TransitionRules.Attach(transitionRule);
                this.ObjectContext.TransitionRules.DeleteObject(transitionRule);
            }
        }
    }
}


